using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

public class PlayerInfoUI : MonoBehaviour
{
    private Image healthSlider;
    private Image ExpSlider;
    private Text levelInfo;

    private Text Money;
    //测试测试
    //哈哈哈
    private void Awake()
    {
        healthSlider = transform.GetChild(0).GetChild(0).GetComponent<Image>();
        ExpSlider = transform.GetChild(1).GetChild(0).GetComponent<Image>();
        levelInfo = transform.GetChild(2).GetComponent<Text>();
        Money = transform.GetChild(3).GetChild(0).GetComponent<Text>();
    }

    private void Update()
    {
        updateExp();
        updateHealth();
        updateLevelText();
        updateMoney();
    }

    void updateHealth()
    {
        float healthSilderPercent = (float)GameManager.Instance.playerStats.currentHealth / GameManager.Instance.playerStats.maxHealth;
        healthSlider.fillAmount = healthSilderPercent;
    }

    void updateExp()
    {
        float expSilderPercent = (float)GameManager.Instance.playerStats.characterData.currentExp / GameManager.Instance.playerStats.characterData.baseExp;
        ExpSlider.fillAmount = expSilderPercent;
    }

    void updateLevelText()
    {
        levelInfo.text = "Level "+GameManager.Instance.playerStats.characterData.currentLevel.ToString("00");
    }

    void updateMoney()
    {
        Money.text = GameManager.Instance.moneyData.MoneyAmount.ToString();
    }

}
